package cn.zjj.fallback;

import cn.zjj.dto.UserTicketDto;
import cn.zjj.enums.GlobalErrorCode;
import cn.zjj.feign.MovieFeignClient;
import cn.zjj.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieFallBackFactory implements FallbackFactory<MovieFeignClient> {
    @Override
    public MovieFeignClient create(Throwable throwable) {
        return new MovieFeignClient() {
            @Override
            public JsonResult select() {
                return JsonResult.error(GlobalErrorCode.SERVICE_FUSING_ERROR);
            }

            @Override
            public JsonResult selectUserTicket(UserTicketDto userTicketDto) {
                return JsonResult.error(GlobalErrorCode.SERVICE_FUSING_ERROR);
            }

            @Override
            public JsonResult selectById(Long id) {
                return JsonResult.error(GlobalErrorCode.SERVICE_FUSING_ERROR);
            }

            @Override
            public JsonResult buyTicket(UserTicketDto buyTicketDto) {
                return JsonResult.error(GlobalErrorCode.SERVICE_FUSING_ERROR);
            }

            @Override
            public JsonResult getAllId() {
                return JsonResult.error(GlobalErrorCode.SERVICE_FUSING_ERROR);
            }
        };
    }

}
